package com.csair.platform.cit.service.controller;

import com.csair.platform.cit.service.core.CheckDataPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.csair.invoice.common.base.vo.JsonResult;
import com.csair.platform.cit.facade.A200000Api;
import com.csair.platform.cit.facade.model.CitQueryParam;
import com.csair.platform.cit.facade.model.a200000.CitMssrSaveVo;
import com.csair.platform.cit.facade.model.a200000.CitNsrxxVo;
import com.csair.platform.cit.facade.model.a200000.CitQtxxVo;
import com.csair.platform.cit.facade.model.a200000.CitSbbxxVo;
import com.csair.platform.cit.facade.model.a200000.CitYhfbxxVo;
import com.csair.platform.cit.service.biz.IA200000Service;
import com.csair.platform.cit.service.core.CheckAnyPermission;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 企业所得税主表数据接口
 * @author caoyu
 *
 */
@Api(tags = "企业所得税主表数据")
@Slf4j
@RestController
public class A200000Controller extends BaseController implements A200000Api {
    
    /**
     * [主表数据]服务
     */
    @Autowired
    IA200000Service a200000Service;
    
    /**
     * 获取[主表数据]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "获取[主表数据]")    
    @Override
    public JsonResult<JSONObject> query(@Validated @RequestBody CitQueryParam param) {
        log.info("获取[主表数据]，请求参数:{}", JSON.toJSONString(param));
        return a200000Service.query(param, getCurrentUser(), false);
    }

    /**
     * 获取主表优惠编码数据
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "获取[主表优惠编码数据]")    
    @Override
    public JsonResult<JSONObject> queryYhbm(@PathVariable String hc) {
        log.info("获取[主表优惠编码数据]，请求参数:{}", hc);
        return a200000Service.queryYhbm(hc);
    }

    /**
     * 保存[主表数据-纳税人信息]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "保存[主表数据-纳税人信息]")
    @Override
    public JsonResult<Void> saveNsrxx(@Validated @RequestBody CitNsrxxVo nsrxxVo) {
        log.info("保存[主表数据-纳税人信息]，请求参数:{}", JSON.toJSONString(nsrxxVo));
        a200000Service.saveNsrxx(nsrxxVo);
        return JsonResult.success();
    }

    /**
     * 保存[主表数据-优惠附表信息]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "保存[主表数据-优惠附表信息]")
    @Override
    public JsonResult<Void> saveYhfbxx(@Validated @RequestBody CitYhfbxxVo yhfbxxVo) {
        log.info("保存[主表数据-优惠附表信息]，请求参数:{}", JSON.toJSONString(yhfbxxVo));
        a200000Service.saveYhfbxx(yhfbxxVo);
        return JsonResult.success();
    }

    /**
     * 保存[主表数据-申报表信息]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "保存[主表数据-申报表信息]")
    @Override
    public JsonResult<Void> saveSbbxx(@Validated @RequestBody CitSbbxxVo sbbxxVo) {
        log.info("保存[主表数据-申报表信息]，请求参数:{}", JSON.toJSONString(sbbxxVo));
        a200000Service.saveSbbxx(sbbxxVo);
        return JsonResult.success();
    }

    /**
     * 保存[主表数据-优惠减免数据 7.*]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "保存[主表数据-优惠减免数据 7.*]")    
    @Override
    public JsonResult<Void> saveMssr(@Validated @RequestBody CitMssrSaveVo mssrxxVo) {
        log.info("保存[主表数据-优惠减免数据 7.*]，请求参数:{}", JSON.toJSONString(mssrxxVo));
        a200000Service.saveMssrxx(mssrxxVo, "7");
        return JsonResult.success();
    }

    /**
     * 保存[主表数据-优惠减免数据 8.*]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "保存[主表数据-优惠减免数据 8.*]")    
    @Override
    public JsonResult<Void> saveSdjm(@Validated @RequestBody CitMssrSaveVo sdjmxxVo) {
        log.info("保存[主表数据-优惠减免数据 8.*]，请求参数:{}", JSON.toJSONString(sdjmxxVo));
        a200000Service.saveMssrxx(sdjmxxVo, "8");
        return JsonResult.success();
    }

    /**
     * 保存[主表数据-优惠减免数据 13.*]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "保存[主表数据-优惠减免数据 13.*]")    
    @Override
    public JsonResult<Void> saveJmsd(@Validated @RequestBody CitMssrSaveVo jmsdxxVo) {
        log.info("保存[主表数据-优惠减免数据 13.*]，请求参数:{}", JSON.toJSONString(jmsdxxVo));
        a200000Service.saveMssrxx(jmsdxxVo, "13");
        return JsonResult.success();
    }
    
    /**
     * 保存[主表数据-其他信息]
     */
    @CheckAnyPermission(values={"qysds", "citReport"})
    @CheckDataPermission
    @ApiOperation(value = "保存[主表数据-其他信息]")
    @Override
    public JsonResult<Void> saveQtxx(@Validated @RequestBody CitQtxxVo qtxxVo) {
        log.info("保存[主表数据-其他信息]，请求参数:{}", JSON.toJSONString(qtxxVo));
        a200000Service.saveQtxx(qtxxVo);
        return JsonResult.success();
    }
}
